﻿using SIPSDk.CallArgs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SIPSDk
{
    public abstract class SIPProvider
    {
        #region 所有对外事件

        #region 注册相关
        
        public event EventHandler<RegStateChangedArgs> RegistrationStateChanged;
        protected void OnRegistrationStateChanged(object sender, RegStateChangedArgs e)
        {
            RegistrationStateChanged?.Invoke(sender, e);
        }

        #endregion

        #region 拨打出去相关事件

        /// <summary>
        /// 拨打状态发生改变
        /// </summary>
        public event EventHandler<CallStateChangeArgs> CallStateChanged;
        protected void OnCallStateChanged(object sender, CallStateChangeArgs e)
        {
            CallStateChanged?.Invoke(sender, e);
        }

        #endregion

        #region 消息来了相关事件

        public event EventHandler<ComingCallArgs> ComingCallReceived;
        protected void OnComingCallReceived(object sender, ComingCallArgs e)
        {
            ComingCallReceived?.Invoke(sender, e);
        }

        public event EventHandler<DTMFMessageReceiveArgs> DTMFMessageComming;
        protected void OnDTMFMessageComming(object sender, DTMFMessageReceiveArgs e)
        {
            DTMFMessageComming?.Invoke(sender, e);
        }

        #endregion

        #endregion

        #region 所有对外方法

        public abstract void InitialSIP();

        /// <summary>
        /// 接听电话
        /// </summary>
        public abstract void Answer();

        /// <summary>
        /// 拒接电话
        /// </summary>
        public abstract void Reject();

        /// <summary>
        /// 打电话
        /// </summary>
        public abstract void Call(string dialedNumber);

        /// <summary>
        /// 取消打电话
        /// </summary>
        public abstract void CallCancel();

        /// <summary>
        /// 挂断电话
        /// </summary>
        public abstract void HangUpCall();

        /// <summary>
        /// 通话保持
        /// </summary>
        public abstract void CallHold();

        /// <summary>
        /// 注册用户
        /// </summary>
        public abstract void RegisterAccount();

        /// <summary>
        /// 取消注册用户
        /// </summary>
        public abstract void UnRegisterAccount();

        /// <summary>
        /// 关闭SIP 在程序结束时调用
        /// </summary>
        public abstract void OffSip();

        /// <summary>
        /// 发送DTMF消息
        /// </summary>
        /// <param name="msg"></param>
        public abstract void SendDTMFMessage(string msg);

        /// <summary>
        /// 检查麦克风设备和扬声器设备
        /// </summary>
        /// <returns></returns>
        public abstract bool CheckDevice();

        #endregion
    }
}
